#include <bits/stdc++.h>
#define MP make_pair
#define Fst first
#define Snd second
using namespace std;
int tac;
int n,m,L,V;
int d[100010],v[100010],a[100010];
int pos[100010];
int ln[1000010],dp[1000010];
bool hav[1000010];
int pre[1000010];
inline void Main()
{
    scanf("%d%d%d%d",&n,&m,&L,&V); fill(hav,hav+L+5,0);
    for (int i=0;i<n;i++) scanf("%d%d%d",&d[i],&v[i],&a[i]);
    for (int i=0;i<m;i++) scanf("%d",&pos[i]),hav[pos[i]]=1;
    pre[0]=0; for (int i=0;i<=L;i++) pre[i+1]=pre[i]+(hav[i] ? 1 : 0);
    fill(ln,ln+L+5,(int)-1e9); int resc=0,mxl=0;
    //cerr <<"----------------------------------------\n";
    for (int i=0;i<n;i++)
    {
        int l=0,r=-1;
        if (!a[i] && v[i]>V) l=d[i],r=L;
        else if (a[i]>0)
        {
            if (v[i]>V) l=d[i],r=L;
            else
            {
                int s=(V*V-v[i]*v[i])/(a[i]*2);
                l=d[i]+s+1,r=L;
            }
        }
        else if (a[i]<0 && v[i]>V)
        {
            int s=(v[i]*v[i]-V*V+(-a[i])*2-1)/((-a[i])*2);
            l=d[i],r=min(L,d[i]+s-1);
        }
        //cerr <<i+1<<" "<<l<<" "<<r<<" $$\n";
        if (l<=r && pre[r+1]-pre[l]>0)
        {
            resc++,ln[r+1]=max(ln[r+1],l),mxl=max(mxl,l);
        }
    }
    for (int i=1;i<=L;i++) ln[i]=max(ln[i],ln[i-1]);
    fill(dp,dp+L+5,(int)1e9); deque<int> dq;
    for (int i=0;i<=L;i++)
    {
        if (!hav[i]) continue;
        while (!dq.empty() && dq.front()<ln[i]) dq.pop_front();
        if (ln[i]==-1e9) dp[i]=1;
        else if (!dq.empty()) dp[i]=dp[dq.front()]+1;
        if (dp[i]!=1e9)
        {
            while (!dq.empty() && dp[dq.back()]>=dp[i]) dq.pop_back();
            dq.push_back(i);
        }
    }
    int resd=1e9; for (int i=mxl;i<=L;i++) resd=min(resd,dp[i]);
    if (!resc) resd=0;
    printf("%d %d\n",resc,m-resd);
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&tac);
    while (tac--) Main();
    return 0;
}